package com.ruoyi.business.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.business.domain.ExtModelFieldMetadataTag;
import com.ruoyi.business.service.IExtModelFieldMetadataTagService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 字段元数据标签Controller
 *
 * @author ruoyi
 * @date 2025-07-18
 */
@RestController
@RequestMapping("/extModelFieldMetadataTag")
public class ExtModelFieldMetadataTagController extends BaseController
{
    @Autowired
    private IExtModelFieldMetadataTagService extModelFieldMetadataTagService;

    /**
     * 查询字段元数据标签列表
     */
    @RequiresPermissions("business:extModelFieldMetadataTag:list")
    @GetMapping("/list")
    public TableDataInfo list(ExtModelFieldMetadataTag extModelFieldMetadataTag)
    {
        startPage();
        List<ExtModelFieldMetadataTag> list = extModelFieldMetadataTagService.selectExtModelFieldMetadataTagList(extModelFieldMetadataTag);
        return getDataTable(list);
    }

    /**
     * 导出字段元数据标签列表
     */
    @RequiresPermissions("business:extModelFieldMetadataTag:export")
    @Log(title = "字段元数据标签", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExtModelFieldMetadataTag extModelFieldMetadataTag)
    {
        List<ExtModelFieldMetadataTag> list = extModelFieldMetadataTagService.selectExtModelFieldMetadataTagList(extModelFieldMetadataTag);
        ExcelUtil<ExtModelFieldMetadataTag> util = new ExcelUtil<ExtModelFieldMetadataTag>(ExtModelFieldMetadataTag.class);
        util.exportExcel(response, list, "字段元数据标签数据");
    }

    /**
     * 获取字段元数据标签详细信息
     */
    @RequiresPermissions("business:extModelFieldMetadataTag:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(extModelFieldMetadataTagService.selectExtModelFieldMetadataTagById(id));
    }

    /**
     * 新增字段元数据标签
     */
    @RequiresPermissions("business:extModelFieldMetadataTag:add")
    @Log(title = "字段元数据标签", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExtModelFieldMetadataTag extModelFieldMetadataTag)
    {
        return toAjax(extModelFieldMetadataTagService.insertExtModelFieldMetadataTag(extModelFieldMetadataTag));
    }

    /**
     * 修改字段元数据标签
     */
    @RequiresPermissions("business:extModelFieldMetadataTag:edit")
    @Log(title = "字段元数据标签", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExtModelFieldMetadataTag extModelFieldMetadataTag)
    {
        return toAjax(extModelFieldMetadataTagService.updateExtModelFieldMetadataTag(extModelFieldMetadataTag));
    }

    /**
     * 删除字段元数据标签
     */
    @RequiresPermissions("business:extModelFieldMetadataTag:remove")
    @Log(title = "字段元数据标签", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(extModelFieldMetadataTagService.deleteExtModelFieldMetadataTagByIds(ids));
    }
    /**
     * 关联模型表，模型字段查询字段元数据标签列表
     */
    @RequiresPermissions("business:extModelFieldMetadataTag:list")
    @GetMapping("/listCombination")
    public AjaxResult listCombination(ExtModelFieldMetadataTag extModelFieldMetadataTag)
    {
        List<ExtModelFieldMetadataTag> list = extModelFieldMetadataTagService.listCombination(extModelFieldMetadataTag);
        return success(list);
    }

}
